﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="LocationManagement.aspx.cs"
    Inherits="WebApplication.Restricted.Management.Company.LocationManagement" %>

<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<%@ Register Assembly="System.Web.Entity, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
    Namespace="System.Web.UI.WebControls" TagPrefix="asp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
    </telerik:RadScriptManager>
    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" DefaultLoadingPanelID="RadAjaxLoadingPanel1">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="LocationsGrid">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="LocationsGrid" LoadingPanelID="RadAjaxLoadingPanel1" />
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManager>
    <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" Skin="Default">
    </telerik:RadAjaxLoadingPanel>
    <telerik:RadGrid ID="LocationsGrid" runat="server" AllowFilteringByColumn="True"
        AllowPaging="True" AllowSorting="True" AutoGenerateDeleteColumn="True" AutoGenerateEditColumn="True"
        GridLines="None" Skin="WebBlue" OnDeleteCommand="LocationsGrid_DeleteCommand"
        OnInsertCommand="LocationsGrid_InsertCommand" OnUpdateCommand="LocationsGrid_UpdateCommand"
        DataSourceID="LocationsEntityDataSource">
        <MasterTableView AutoGenerateColumns="False" DataKeyNames="Id" CommandItemDisplay="Top"
            EditMode="EditForms" DataSourceID="LocationsEntityDataSource">
            <RowIndicatorColumn>
                <HeaderStyle Width="20px"></HeaderStyle>
            </RowIndicatorColumn>
            <ExpandCollapseColumn>
                <HeaderStyle Width="20px"></HeaderStyle>
            </ExpandCollapseColumn>
            <Columns>
                <telerik:GridBoundColumn DataField="Id" DataType="System.Int32" HeaderText="Id"
                    SortExpression="Id" UniqueName="Id" Visible="false">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="Name" HeaderText="Name" SortExpression="Name"
                    UniqueName="Name">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="AddressStreet" HeaderText="Ulica" SortExpression="AddressStreet"
                    UniqueName="AddressStreet">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="AddressBuildingNumber" HeaderText="AddressBuildingNumber"
                    SortExpression="AddressBuildingNumber" UniqueName="AddressBuildingNumber" Visible="false">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="AddressLocalNumber" HeaderText="AddressLocalNumber"
                    SortExpression="AddressLocalNumber" UniqueName="AddressLocalNumber" Visible="false">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="CityName" HeaderText="Miasto" SortExpression="CityName"
                    UniqueName="CityName">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="ChainStoreName" HeaderText="Sieć handlowa" SortExpression="ChainStoreName"
                    UniqueName="ChainStoreName">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="ParentLocationName" HeaderText="Sklep nadrzędny"
                    SortExpression="ParentLocationName" UniqueName="ParentLocationName">
                </telerik:GridBoundColumn>
            </Columns>
            <EditFormSettings EditFormType="WebUserControl" UserControlName="~/Controls/Management/Company/LocationEditControl.ascx">
                <EditColumn UniqueName="EditCommandColumn1">
                </EditColumn>
            </EditFormSettings>
        </MasterTableView>
    </telerik:RadGrid>
    <asp:EntityDataSource ID="LocationsEntityDataSource" runat="server" ConnectionString="name=MerchModelEntities"
        DefaultContainerName="MerchModelEntities" CommandText="
        select location.Id as Id, location.Name as Name, 
        address.Street as AddressStreet, address.BuildingNumber as AddressBuildingNumber, address.LocalNumber as AddressLocalNumber,
        city.Name as CityName,
        chainStore.Name as ChainStoreName,
        parentLocation.Name as ParentLocationName
        from MerchModelEntities.Location as location join MerchModelEntities.Address as address on location.Address = address join MerchModelEntities.City as city on address.City = city left outer join MerchModelEntities.ChainStore as chainStore on location.ChainStore = chainStore left outer join MerchModelEntities.Location as parentLocation on location.ParentLocation = parentLocation"
        Select="it.[Id], it.[Name], it.[AddressStreet], it.[AddressBuildingNumber], it.[AddressLocalNumber], it.[CityName], it.[ChainStoreName], it.[ParentLocationName]"
        OrderBy="it.[Id]">
    </asp:EntityDataSource>
    </form>
</body>
</html>
